const fs = require('fs');
const Base = require('./base.js');

module.exports = class extends Base {
  uploadAction() {
    // 获取文件
    let file = think.extend({}, this.file('file'));

    // 保存文件的路径
    let savepath =think.ROOT_PATH + '/www/static/uploadfiles/';
    let filepath = file.path; //文件路径
    let filename = file.name; //文件名

    let datas = fs.readFileSync(filepath);
    fs.writeFileSync(savepath + filename, datas);
    return this.json({url: `http://127.0.0.1:8360/static/uploadfiles/${filename}`})
  }
};
